package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 用户异常枚举
 * <p>
 * Created by yaosy on 2018年6月11日
 */
public enum ResourcesExceptionEnum implements CustomExceptionCode {

    RESOURCES_NOT_ID(600, "资源id为空", 900),
    RESOURCES_NOT_MSG(602, "资源不存在", 900),
    MODIFLY_RESOURCES_ERROR(603, "该资源文件或目录已存在", 900),
    ADD_RESOURCES_ERROR(604, "已存在相同资源文件名", 900),
    RESOURCES_GET_ERROR(605, "查询资源失败！", 900),
    RESOURCES_MODIFY_ERROR(606, "修改资源失败！", 900),
    RESOURCES_ADD_ERROR(608, "新增资源失败！", 900),
    RESOURCES_EXISTS_ERROR(609, "该文件包含子文件！", 900),
    RESOURCES_DELETE_ERROR(610, "删除文件失败！", 900),
    RESOURCES_RENAME_ERROR(611, "文件重命名失败！", 900),
    RESOURCES_WRITER_ERROR(612, "写入资源文件失败！", 900),
    RESOURCES_CONENT_ERROR(613, "创建文件失败！", 900),
    ADD_RESOURCES_EXISTS_ERROR(614, "已存在相同资源目录！", 900),
    FAIL_RESOURCES_ERROR(615, "资源目录创建失败！", 900),
    RESOURCES_NOT_SITEID(616, "站点id为空！", 900),
    RESOURCES_NOT_ISDIRECTORY(617, "是否目录为空！", 900),
    RESOURCES_NOT_EDIT_ISDIRECTORY(618, "顶级目录,不能修改！", 900),
    RESOURCES_UPLOAD_FAILED(619, "上传文件失败！", 900),
    RESOURCES_IS_DIRECTORY_FAILED(620, "请选择文件夹目录上传！", 900),
    RESOURCES_PATH_FAILED(621, "上传路径不存在！", 900),
    RESOURCES_EXISTS_FAILED(622, "同一级目录不能存在相同文件名！", 900),
    RESOURCES_EXISTS_NAME_FAILED(623, "该目录存在下级文件,不能被修改！", 900),

    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    ResourcesExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }


    public static ResourcesExceptionEnum getEnumByCode(Integer code){
        for(ResourcesExceptionEnum siteExceptionEnum : ResourcesExceptionEnum.values()){
            if(code.equals(siteExceptionEnum.getCode())){
                return siteExceptionEnum;
            }
        }
        return null;
    }
}
